package com.glela.common.util;

import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.commons.collections4.map.HashedMap;

import com.glela.common.beans.Sms;

public class SmsUtil {
	private static ExecutorService	executorService	= Executors.newFixedThreadPool(10);
	
	public static String sendSms(Sms sms) {
		String url = "http://www.jianzhou.sh.cn/JianzhouSMSWSServer/http/sendBatchMessage";
		String account = "sdk_xiaozhuang";
		String pwd = "hvf2v8xh";
		try {
			Map<String,Object> paramMap = new HashedMap<>();
			paramMap.put("account", account);
			paramMap.put("password", pwd);
			paramMap.put("destmobile", sms.getMobile());
			paramMap.put("msgText", sms.getContext());
			paramMap.put("sendDateTime", "");
			System.out.println(HttpUtil.post(url, paramMap));
			return null;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static void syncSendSms(final Sms sms) {
		executorService.execute(new Runnable() {
			@Override
			public void run() {
				sendSms(sms);
			}
		});
	}
	public static void main(String args[]) {
		Sms s = new Sms();
		s.setMobile("13122319348");
		s.setContext("您在小铺来了申请提现到 中国工商银行 9558******1111 张三三，请核实是否本人操作，如有问题请及时联系小铺客服4005122 【校妆网】");
		syncSendSms(s);
	}
	
}
